"use strict";

(function () {
  function r(e, n, t) {
    function o(i, f) {
      if (!n[i]) {
        if (!e[i]) {
          var c = "function" == typeof require && require;
          if (!f && c) return c(i, !0);
          if (u) return u(i, !0);
          var a = new Error("Cannot find module '" + i + "'");
          throw a.code = "MODULE_NOT_FOUND", a;
        }

        var p = n[i] = {
          exports: {}
        };
        e[i][0].call(p.exports, function (r) {
          var n = e[i][1][r];
          return o(n || r);
        }, p, p.exports, r, e, n, t);
      }

      return n[i].exports;
    }

    for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
      o(t[i]);
    }

    return o;
  }

  return r;
})()({
  1: [function (require, module, exports) {
    "use strict";

    var shares = null;
    var Intent = null,
        File = null,
        Uri = null,
        main = null;
    var aid = null,
        aname = null,
        acon = null,
        atime = null,
        aadd = null,
        amoney = null,
        anumber = null; // H5 plus事件处理

    function plusReady() {
      updateSerivces();

      if (plus.os.name == "Android") {
        main = plus.android.runtimeMainActivity();
        Intent = plus.android.importClass("android.content.Intent");
        File = plus.android.importClass("java.io.File");
        Uri = plus.android.importClass("android.net.Uri");
      }
    }

    if (window.plus) {
      plusReady();
    } else {
      document.addEventListener("plusready", plusReady, false);
    }
    /**
     * 
     * 更新分享服务
     */


    function updateSerivces() {
      plus.share.getServices(function (s) {
        shares = {};

        for (var i in s) {
          var t = s[i];
          shares[t.id] = t;
        }
      }, function (e) {
        alert("获取分享服务列表失败：" + e.message);
      });
    }
    /**
       * 分享操作
       * @param {JSON} sb 分享操作对象s.s为分享通道对象(plus.share.ShareService)
       * @param {Boolean} bh 是否分享链接
       */


    function shareAction(sb, bh) {
      if (!sb || !sb.s) {
        alert("无效的分享服务！");
        return;
      }

      var msg = {
        content: '',
        extra: {
          scene: sb.x
        }
      };
      var webMsg = "?actId=" + aid + "&actName=" + aname + "&actContent=" + acon + "&actTime=" + atime + "&actAddress=" + aadd + "&actMoney=" + amoney + "&actNumber=" + anumber;
      msg.thumbs = ["http://121.89.201.29:5000/static/icons/theme.png"];
      msg.pictures = ["http://121.89.201.29:5000/static/icons/theme.png"];
      msg.href = 'http://www.funtogether.top/share' + webMsg;
      msg.title = '聚欢活动分享';
      msg.content = '我分享了聚欢上的活动，快啦围观哦！'; // 发送分享

      if (sb.s.authenticated) {
        // alert("---已授权---");
        shareMessage(msg, sb.s);
      } else {
        alert("---未授权---");
        sb.s.authorize(function () {
          shareMessage(msg, sb.s);
        }, function (e) {
          alert("认证授权失败：" + e.code + " - " + e.message);
        });
      }
    }
    /**
       * 发送分享消息
       * @param {JSON} msg
       * @param {plus.share.ShareService} s
       */


    function shareMessage(msg, s) {
      // alert(JSON.stringify(msg));
      s.send(msg, function () {
        alert("分享到\"" + s.description + "\"成功！ ");
      }, function (e) {
        alert("分享到\"" + s.description + "\"失败: " + JSON.stringify(e));
      });
    } // 分析链接


    function shareHref(actId, actName, actContent, actTime, actAddress, actMoney, actNumber) {
      var shareBts = [];
      aid = actId;
      aname = actName;
      acon = actContent;
      atime = actTime;
      aadd = actAddress;
      amoney = actMoney;
      anumber = actNumber; // 更新分享列表

      var ss = shares['weixin'];
      ss && ss.nativeClient && (shareBts.push({
        title: '微信朋友圈',
        s: ss,
        x: 'WXSceneTimeline'
      }), shareBts.push({
        title: '微信好友',
        s: ss,
        x: 'WXSceneSession'
      }));
      ss = shares['qq'];
      ss && ss.nativeClient && shareBts.push({
        title: 'QQ',
        s: ss
      }); // 弹出分享列表

      shareBts.length > 0 ? plus.nativeUI.actionSheet({
        title: '分享链接',
        cancel: '取消',
        buttons: shareBts
      }, function (e) {
        e.index > 0 && shareAction(shareBts[e.index - 1], true);
      }) : plus.nativeUI.alert('当前环境无法支持分享链接操作!');
    } // export default{
    //   shareHref // 因为我使用的是vue 所以对外输出给vue使用
    // }

  }, {}]
}, {}, [1]);